//package com.kungfuhacking.wristbandpro.my.activity;
//
//import android.content.Intent;
//import android.os.Bundle;
//import android.support.v4.widget.SwipeRefreshLayout;
//import android.support.v7.widget.DefaultItemAnimator;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.view.View;
//
//import com.kungfuhacking.wristbandpro.R;
//import com.kungfuhacking.wristbandpro.base.view.BaseActivity;
//import com.kungfuhacking.wristbandpro.custom.TitleBarView;
//import com.kungfuhacking.wristbandpro.location.bean.OldEntity;
//import com.kungfuhacking.wristbandpro.my.presenter.FamilyAdapter;
//import com.kungfuhacking.wristbandpro.my.presenter.IFamilyPresenter;
//import com.kungfuhacking.wristbandpro.my.view.IFamilyView;
//import com.kungfuhacking.wristbandpro.widget.swipe.DividerItemDecoration;
//import com.kungfuhacking.wristbandpro.widget.swipe.OnItemClickListener;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * 老人列表页面
// * Created by Aaron on 17/5/15.
// */
//
//public class OldListActivity extends BaseActivity implements IFamilyView, SwipeRefreshLayout.OnRefreshListener {
//
//    private RecyclerView recycleView;
//    private IFamilyPresenter iFamilyPresenter = new IFamilyPresenter(this);
//    private List<OldEntity> oldEntities = new ArrayList<>();
//    private FamilyAdapter familyAdapter;
//    private SwipeRefreshLayout swipeRefreshLayout;
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//
//        setContentView(R.layout.activity_my_family);
//        initWidget();
//
//    }
//
//    @Override
//    protected void onResume() {
//        super.onResume();
//        iFamilyPresenter.familyInfo();
//    }
//
//    private void initWidget() {
//        swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
//        //为SwipeRefreshLayout设置监听事件
//        swipeRefreshLayout.setOnRefreshListener(this);
////        //为SwipeRefreshLayout设置刷新时的颜色变化，最多可以设置4种
//        swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
//                android.R.color.holo_green_light,
//                android.R.color.holo_orange_light,
//                android.R.color.holo_red_light);
//        recycleView = (RecyclerView) findViewById(R.id.recycleView);
//        TitleBarView tbv = (TitleBarView) findViewById(R.id.tbv);
//        tbv.setOnLeftClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                finish();
//            }
//        });
//        initRecycleView();
//    }
//
//    private void initRecycleView() {
//        recycleView.setLayoutManager(new LinearLayoutManager(this));
//        recycleView.setItemAnimator(new DefaultItemAnimator());
//        familyAdapter = new FamilyAdapter(this, oldEntities, mApplication);
//        recycleView.setAdapter(familyAdapter);
//        recycleView.addItemDecoration(new DividerItemDecoration(this,
//                DividerItemDecoration.VERTICAL_LIST,
//                getResources().getDrawable(R.color.bg_gray)));
//        recycleView.addOnItemTouchListener(new OnItemClickListener(recycleView) {
//            @Override
//            public void onItemClick(RecyclerView.ViewHolder holder, int position) {
//
//                Intent mIntent = new Intent(OldListActivity.this, OldDetailActivity.class);
//                if (oldEntities != null) {
//                    mIntent.putExtra("id", oldEntities.get(position).getId());
//                    mIntent.putExtra("level", oldEntities.get(position).getLevel());
//                }
//                startActivity(mIntent);
//            }
//
//            @Override
//            public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
//
//            }
//        });
//
//    }
//
//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
//        iFamilyPresenter.clearRequest();
//    }
//
//    @Override
//    public void setAdapterData(List<OldEntity> oldEntities) {
//        this.oldEntities = oldEntities;
//        familyAdapter.setOldEntities(oldEntities);
//        familyAdapter.notifyDataSetChanged();
//    }
//
//    @Override
//    public void onRefresh() {
//
//        oldEntities.clear();
//        familyAdapter.setOldEntities(oldEntities);
//        familyAdapter.notifyDataSetChanged();
//        iFamilyPresenter.familyInfo();
//        //结束后停止刷新
//        swipeRefreshLayout.setRefreshing(false);
//    }
//}
